'use strict'

const Service = require('egg').Service

class CommentService extends Service {
  // 获取评论
  getComment(leaveword_id) {
    const { app } = this
    return app.model.Comment.findAll({
      where: { leaveword_id },
      include: [
        {
          model: app.model.User,
          as: 'user',
          attributes: ['username', 'nickname', 'avatar']
        }
      ],
      order: [['id', 'DESC']]
    })
  }
}

module.exports = CommentService
